﻿@model IEnumerable<Gfw.Web.Models.Genealogy.UserGenealogyModel>
@using C.Mvc
@using Gfw.Infrastructure.User
@using MvcContrib.UI.Grid;


@using (Ajax.BeginForm("List", "UserGenealogy", null, Gfw.Web.Common.ViewHelper.AjaxGet))
{
   @* <table id="mytable" cellpadding="0" cellspacing="0">
        <thead>
            <tr>
                <th>水平</th>
                <th>用户</th>
                <th>父级</th>
                <th>父节点</th>
                <th>推荐人</th>
                <th>左孩子</th>
                <th>右孩子</th>
            </tr>
        </thead>
       @{ int i = 0; }
        @foreach(var m in Model)
        {
            var color = i%2 == 0 ? "fff" : "efefef";
            i++;
            <tr style=" background:@color">
                <td>@m.n</td>
            </tr>
        }
    </table>*@
    @Html.Grid(Model).Columns(
        column =>
        {
            column.For(x => string.Format("{0}.{1}", x.H, x.Hindex)).Named("水平");
            column.Custom(@<text>
                                  
                                   @{
                                       if (!string.IsNullOrEmpty(item.Id))
                                       {
                                           
                                           <a href=" @Url.Action("Index1", new { u = item.LoginName }) ">
                                            注册名： @item.LoginName<br />
                                            注册序号： @item.UserIndex
                                           </a>
                                       }
                                       else
                                       {
                                       
                                           @Html.ActionLink("添加用户", "Register", "User", new { cn = item.CodeNumber }, null)
                                       }
                                   }
                                
                               </text>).Named("用户").Attributes(align => "left");
            column.Custom(@<text>
                                  
                                   @{
                                       if (!string.IsNullOrEmpty(item.Id))
                                       {
                                           if (item.IsActivation == (int)UserStatusEnum.Normal)
                                           {
                                               
                                               <img src='@Html.ActionLink("~/Images/user_has.png")'  title="已激活" />

                                           }
                                           else
                                           {
                                               <img src='@Url.Content("~/Images/user_unactive.png")' title="未激活" />
                                           } 
                                       }
                                       else
                                       {
                                           <img src='@Url.Content("~/Images/user_add.png")'  title="虚位以待" />
                                       }
                                   }
                                
                               </text>).Named("状态").Attributes(align => "center");
            
        column.For(x => x.ParentHindex).Named("父级");
            column.For(x => x.ParentName).Named("父节点");
            column.For(x => x.RecommenderName).Named("推荐人");
            column.For(x => x.LeftChildren).Named("左孩子");
            column.For(x => x.RightChildren).Named("右孩子");
            // column.For(c => c.CodeNumber);


        }
               ).Attributes(id => "mytable", cellpadding => "0", cellspacing => "0")
    ;

    Random r = new Random();

    @Ajax.DataGridPager().Totals(ViewBag.TotalPage).PageIndex(ViewBag.PageIndex).PagePropertyName("page").AjaxOptions(Gfw.Web.Common.ViewHelper.AjaxGet).Model(new { r = r.NextDouble() })
    

}